//
//  WKAVPlayerVC.m
//  WKMaybell
//
//  Created by 何文虎 on 2018/12/6.
//  Copyright © 2018年 何文虎. All rights reserved.
//

#import "WKAVPlayerVC.h"


@interface WKAVPlayerVC ()
{
     
}
@property(nonatomic,strong)LXAVPlayView *playerview;

@property(nonatomic,strong)UIView *playFatherView;
@end

@implementation WKAVPlayerVC

- (void)viewDidLoad {
    [super viewDidLoad];
    [self initViews];
}

- (void)initViews{
    self.view.backgroundColor =[UIColor whiteColor];
    
    self.playFatherView =[[UIView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, ScreenHeight)];
    self.playFatherView.backgroundColor = [UIColor yellowColor];
    [self.view addSubview:self.playFatherView];
    
    
//  NSString *url = @"http://vip.okokbo.com/20180117/BNp2mT7Q/index.m3u8";
   
  NSString *url = @"https://xingchenxueyuan.oss-cn-beijing.aliyuncs.com/20180521/%E5%B0%8F%E6%B0%94%E6%B3%A1%E6%88%90%E7%89%87%E6%AD%A3%E5%B8%B8%E8%82%8C%E8%82%A4%E6%B5%81%E7%A8%8B.mp4";
    
//    NSString *url = @"https://douboshi.oss-cn-beijing.aliyuncs.com/20181219/f613d71f266d40f6952c3e650e610d77.mp4";
//    NSString *url = @"http://wvideo.spriteapp.cn/video/2016/0328/56f8ec01d9bfe_wpd.mp4";
  
    LXPlayModel *model =[[LXPlayModel alloc]init];
    model.playUrl = url;
    model.videoTitle = @"绝密飞行";
    model.fatherView = self.playFatherView;
    self.playerview =[[LXAVPlayView alloc]init];
    
    self.playerview.isLandScape = YES;
    
    self.playerview.isAutoReplay = NO;
    
    self.playerview.currentModel = model;
    self.navigationItem.leftBarButtonItem =[[UIBarButtonItem alloc]initWithTitle:@"返回" style:UIBarButtonItemStylePlain target:self action:@selector(backAction)];
    
    
    WHWeakSelf(weakSelf);
    self.playerview.backBlock = ^{
        
        [weakSelf.navigationController popViewControllerAnimated:YES];
    };
    
}


-(void)viewWillDisappear:(BOOL)animated{
    [super viewWillDisappear:animated];
    [self.playerview destroyPlayer];
    
}
-(void)backAction{
    [self.navigationController popViewControllerAnimated:YES];
}
-(BOOL)shouldAutorotate{
    return YES;
}
// 支持哪些屏幕方向
- (UIInterfaceOrientationMask)supportedInterfaceOrientations {
    return UIInterfaceOrientationMaskAll;
}
- (UIStatusBarStyle)preferredStatusBarStyle {
    return UIStatusBarStyleDefault;
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
